import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class InputCardWidgetNew extends StatelessWidget {
  final String hintText;
  final String title;
  final TextEditingController contro;
  final EdgeInsets margin;
  TextInputAction textAction;
  ValueChanged<String> enterListen;

  bool enabled;
  bool isPassWord;
  Widget suffixIcon;
  TextInputType keyboardType;
  List<TextInputFormatter> inputFormatters;
  Function onChange;

  Border border;

  InputCardWidgetNew(
      {this.hintText,
      this.contro,
      @required this.title,
      this.margin,
      this.onChange,
      this.border,
      this.enterListen,
      this.textAction,
      this.enabled = true,
      this.isPassWord = false,
      this.inputFormatters,
      this.suffixIcon,
      this.keyboardType});

  @override
  Widget build(BuildContext context) {
    if (border == null) {
      border = Border(bottom: BorderSide(width: 1, color: Color(0xffefefef)));
    }
    if (inputFormatters == null) {
      inputFormatters = [];
    }
    return Container(
      width: double.infinity,
      margin: margin,
      padding: EdgeInsets.only(left: 16, right: 16),
      decoration: BoxDecoration(color: Colors.white, border: border),
      child: TextField(
          inputFormatters: inputFormatters,
          controller: contro,
          keyboardType: keyboardType,
          autocorrect: true,
          obscureText: isPassWord,
          textInputAction: textAction,
          onSubmitted: enterListen,
          onChanged: (text) {
            onChange();
          },
          decoration: InputDecoration(
              enabled: enabled,
              hintText: hintText,
              hintStyle: TextStyle(fontSize: 16),
              icon: Text(
                title,
                style: TextStyle(fontSize: 16),
              ),
              suffixIcon: suffixIcon,
              border: InputBorder.none,
              contentPadding: EdgeInsets.only(left: -8, top: 15, bottom: 15))),
    );
  }
}
